//
// Static file serving test:
// Serves tests/images/ directory as static files.
// Images are used in index.html
//

var JServer = require( '../jserver' );
var server = new JServer( {workers:1} );
server.ServerResponse.allowOrigin = '*';
if ( server.start() ) return;

var FileCache = require( '../filecache' );
var cache = new FileCache( {rootPath:__dirname, maxSize:1600, verbose:true} ); // small size to test dropLRU
cache.verbose = true;

server.get( cache.dirSync('/images',true), cache.handle.bind(cache) );
/*
// OR...
server.get( cache.dirSync('/images'), function(req,res) {
	cache.sendFile( req.urlc.pathname, res, function(err) {
		if (err) console.error("ERROR: "+err);
	} );
} );
// OR...
server.get( cache.dirSync('/images'), function(req,res) {
	cache.handle( req, res, function(err) {
		if (err) console.error("ERROR: "+err);
	} );
} );
*/

server.listenHTTP( 3003 );
